import 'yl_double_click.dart';
import 'package:flutter/material.dart';

//
extension YLWidget on Widget {
  //
  Widget removeAll(context) {
    return MediaQuery.removePadding(
        context: context,
        removeBottom: true,
        removeLeft: true,
        removeRight: true,
        removeTop: true,
        child: this);
  }

  Widget margin(EdgeInsetsGeometry padding) {
    return Padding(padding: padding, child: this);
  }

  Widget toFlex({int flex = 1}) {
    return Expanded(flex: flex, child: this);
  }

  Widget toFlexible({int flex = 1}) {
    return Flexible(flex: flex, child: this);
  }

  Widget toVisibility({bool visible = true}) {
    return Visibility(visible: visible, child: this);
  }

//
  Widget effectGesture(
          {int effecttime = 1500, bool hasEffect = false, Function()? onTap}) =>
      InkWell(
        onTap: () {
          if (YLDoubleClick.disapleClick(validtime: effecttime) && hasEffect) {
            return;
          }
          if (onTap != null) {
            onTap();
          }
        },
        splashColor: Colors.transparent,
        highlightColor: Colors.transparent,
        child: this,
      );
}
